package com.c.ctgproject.adapter.review

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.c.ctgproject.R
import com.c.ctgproject.entity.review.CarReviewEntity
import com.c.ctgproject.mode.ReviewEnum
import com.c.ctgproject.utils.handlerNull
import org.jetbrains.anko.textColorResource

/**
 *作者:LiBW
 *创建日期: 2020/9/11
 *描述: 报废车价格申请审核 已同意和已拒绝
 */
class ReviewCarCommonAdapter(private val context: Context, private val mList: List<CarReviewEntity.DataBean.ListBean>) : RecyclerView.Adapter<ReviewCarCommonAdapter.ViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.item_review_car_common_list, parent, false)
        return ViewHolder(view)
    }

    override fun getItemCount(): Int {
        return mList.size
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val data=mList[position]
        holder.mCarPlateTV.text=data.ownerPlate.handlerNull()
        holder.mTimeTV.text=data.createTime.handlerNull()
        holder.mCarOwnerTV.text=data.carOwner.handlerNull()
        holder.mPriceTV.text=data.applicationPrice.handlerNull()
        holder.mApplyMarkTV.text=data.remark.handlerNull()
        when (data.isPass) {
            ReviewEnum.UN_REVIEWED.code -> {
                holder.mReviewResultTV.text = ReviewEnum.UN_REVIEWED.statueName
                holder.mReviewResultTV.textColorResource = ReviewEnum.UN_REVIEWED.color

            }
            ReviewEnum.AGREE.code -> {
                holder.mReviewResultTV.text = ReviewEnum.AGREE.statueName
                holder.mReviewResultTV.textColorResource = ReviewEnum.AGREE.color

            }
            ReviewEnum.REFUSE.code -> {
                holder.mReviewResultTV.text = ReviewEnum.REFUSE.statueName
                holder.mReviewResultTV.textColorResource = ReviewEnum.REFUSE.color
            }
        }
        holder.mReviewMarkTV.text=data.auditRemark.handlerNull()
    }

    inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
            val mCarPlateTV:TextView=itemView.findViewById(R.id.mOrderIdTV)
            val mTimeTV:TextView=itemView.findViewById(R.id.mTimeTV)
            val mCarOwnerTV:TextView=itemView.findViewById(R.id.mCarOwnerTV)
            val mPriceTV:TextView=itemView.findViewById(R.id.mPriceTV)
            val mApplyMarkTV:TextView=itemView.findViewById(R.id.mApplyMarkTV)
            val mReviewResultTV:TextView=itemView.findViewById(R.id.mReviewResultTV)
            val mReviewMarkTV:TextView=itemView.findViewById(R.id.mReviewMarkTV)

    }
}